package com.jdb.versailles.dao.impl;

//imports..
import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.jdb.versailles.dao.ClientDao;
import com.jdb.versailles.model.Client;
 
@Repository
@SuppressWarnings({"unchecked", "rawtypes"})
public class ClientDaoImpl implements ClientDao{
  @Autowired 
  private SessionFactory sessionFactory;  
  
  public void saveClient(Client client) {
	    Session session = sessionFactory.getCurrentSession();
	    System.out.println("sauvegarde client");
	    session.save(client);
	    System.out.println("fin sauvegarde client");
	  }
 
  public List<Client> findAll() {
    Session session = sessionFactory.getCurrentSession();
    System.out.println("recuperation de tout mes clients");
    List clients = session.createQuery("from Client").list();
    System.out.println("fin recuperation client");
    return clients;
  }
}